<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>${title}</title>
    <style type="text/css">
      @media screen {
        body {
          background-color: rgb(255, 255, 255);
          font-family:      arial, verdana, trebuchet, officina, sans-serif;
        }
      }
  
      @media print { 
        body {
          background-color: rgb(255, 255, 255);
          font-family:      arial, verdana, trebuchet, officina, sans-serif;
        }

        a {
          text-decoration: none;
        }

        .HeadingTable, .SubHeadingTable, .GroupHeadingTable , .GroupEndTable {
          border-width: 2px;
          border-style: solid;
          border-color: rgb(150,150,150);
        }
        
        .ResultBlockHeading {
          border-width: 1px;
          border-style: solid;
          border-color: rgb(150,150,150);
        }
        
        table.ResultTable, table.OverviewTable, table.CheckStatisticsTable {
          border-collapse: collapse;
        }
        
        td.DefaultCell, td.DefineCell, td.NumberCell, td.NumberCellPositiveResult, td.NumberCellNegativeResult, 
        td.NumberCellErrorResult, td.NumberCellInconclusiveResult, td.NumberCellNoneResult, td.NumberCellNoColor,
        td.PositiveResultCell, td.NegativeResultCell, td.WarningCell, td.NoneResultCell, td.InconclusiveResultCell,
        td.ErrorResultCell, th.TableHeadingCell {
          border-width: 1px;
          border-style: solid;
          border-color: rgb(150,150,150);
        }
        
        .PatternSeparator {         
          border-style: none;
        }
        
        .PositiveResult {
          border-bottom: 2px solid;
        }
        
        .NegativeResult {
          border-bottom: 2px solid;
        }
        
        .NoneResult { 
          border-bottom: 2px solid;
        }
        
        .InconclusiveResult {
          border-bottom: 2px solid;
        }
        
        .ErrorResult {
          border-bottom: 2px solid;
        }

        
        .TestcaseHeadingDefaultResult {
          border-bottom: 2px solid;
        }
        
        .TestcaseHeadingPositiveResult {
          border-bottom: 2px solid;
        }
        
        .TestcaseHeadingNegativeResult {
          border-bottom: 2px solid;
        }
        
        table.ScreenOnly, a.Undecorated, .LinkCell {
          display: none;
        }
      }
      
      a.Undecorated:hover {
        color:red;
      }

      a.Undecorated { 
        text-decoration: none; 
      }
      
      .NavStyle {
        background-color: rgb(220, 221, 222);
      }
      
      td.LinkCell, td.UpCell {  
        width:              1px;
        white-space:        nowrap;
      }

      table {
        margin-bottom:    10px;
        vertical-align:   top; 
        border:           0;
        border-spacing:   1px;
        padding:          2px;
      }

      table.ScreenOnly {
        vertical-align: top; 
        margin-bottom:  10px;
      }

      .NoMarginBottom {
        margin-bottom:    0px;
      }
      
      .HeadingTable {
        width:            100%;
        text-align:       center;
        margin-top:       15px;
        margin-bottom:    30px;
        margin-left:      auto;
        margin-right:     auto;
        background-color: rgb(220, 221, 222);
      }
      
      .SubHeadingTable {
        width:            100%;
        text-align:       center;
        margin-top:       15px;
        margin-bottom:    25px;
        background-color: rgb(220, 221, 222);
      }
      
      .GroupHeadingTable, .GroupEndTable {
        width:            100%;
        text-align:       center;
        margin-top:       15px;
        padding-right:    20px;
        background-color: rgb(220, 221, 222);
      }
      
      .DefaultTable {
        padding:        0px;
        border-spacing: 0px;
      }
      
      .CheckStatisticsTable {
        margin-bottom: 8px;
        padding-right:  20px;
      }
  
      .OverviewTable {
        text-align:     left;
      }
      
      .OverviewResultTable {
        width:          100%;
        margin-bottom:  0px;
        border-spacing: 0px;
        padding:        0px;
        text-align:     center;
      }
      
      .ResultTable {
        width:          100%;
        text-align:     left;
        padding-right:  20px;
      }
      
      .ResultTableInner {
        width:          100%;
        text-align:     left;
        padding-right:  0px;
      }
  
      table.ResultTable td, table.ChildLinkTable td {
        vertical-align: top;
      }

      .ChildLinkTable {
        width:          1px;
        text-align:     left;
      }

      .InfoTable {
        text-align:     left;
        padding-right:  0px;
        margin-bottom:  0px;
        border-spacing: 0px;
      }

      .InfoTableExpand {
        width:          100%;
        text-align:     left;
        padding-right:  0px;
        margin-bottom:  0px;
        border-spacing: 0px;
      }

      .OverallResultTable {
        width:         100%;
        text-align:    center;
        margin-bottom: 20px;
        margin-left:   auto;
        margin-right:  auto;
        font-weight:   bold;
      }
      
      .TableHeadingCell {
        background-color: rgb(179, 179, 179);
        font-family:      arial, verdana, trebuchet, officina, sans-serif;
        font-weight:      bold;
        text-align:       center;
      }
  
      .CellNoColor {
        text-align:     left;
        vertical-align: top;
      }   
      
      .DefineCell {
        background-color: rgb(179, 179, 179);
        text-align:       left;
      }
      
      .DefaultCell, .DefaultCellBold {
        background-color: rgb(229, 229, 229);
        text-align:       left;
      }
      
      .DefaultCellBold {
        font-weight:      bold;
      }
        
      .NumberCell {
        background-color: rgb(229, 229, 229);
        text-align:       center;
        min-width:        50px;
      }
      
      .NumberCellNegativeResult {
        background-color: rgb(240, 0, 0);
        text-align:       center;
        min-width:        50px;
      }
      
      .NumberCellPositiveResult {
        background-color: rgb(25, 165, 88);
        text-align:       center;
        min-width:        50px;
      }
      
      .NumberCellNoneResult {
        background-color: rgb(105, 105, 105);
        text-align:       center;
        min-width:        50px;
      }
      
      .NumberCellInconclusiveResult {
        background-color: rgb(255, 165, 0);
        text-align:       center;
        min-width:        50px;
      }
      
      .NumberCellErrorResult {
        background-color: rgb(205, 0, 0);
        text-align:       center;
        min-width:        50px;
      }
      
      .NumberCellNoColor {        
        text-align: center;
      }
      
      .PositiveResultCell {
        background-color: rgb(25, 165, 88);
      }
    
      .NegativeResultCell {
        background-color: rgb(240, 0, 0);
      }
      
      .NoneResultCell {
        background-color: rgb(105, 105, 105);
      }
      
      .InconclusiveResultCell {
        background-color: rgb(255, 165, 0);
      }
      
      .ErrorResultCell {
        background-color: rgb(205, 0, 0);
        white-space:        nowrap;
      }

      .WarningCell {
        background-color: rgb(255, 255, 0);
      }

      .TestcaseHeadingDefaultResult {
        background-color: rgb(179, 179, 179);
      }

      .TestcaseHeadingPositiveResult {
        background-color: rgb(25, 165, 88);
      }   

      .TestcaseHeadingNegativeResult {
        background-color: rgb(240, 0, 0);
      }    

      .TestcaseHeadingNoneResult {
        background-color: rgb(105, 105, 105);
      }

      .TestcaseHeadingInconclusiveResult {
        background-color: rgb(255, 165, 0);
      }

      .TestcaseHeadingErrorResult {
        background-color: rgb(205, 0, 0);
      }
      
      .PatternSeparator {
        height: 0.2em;
      }
      
      .NegativeResult {
        background-color: rgb(240, 0, 0);
        text-align:       center;
        font-weight:      bold;
      }

      .PositiveResult {
        background-color: rgb(25, 165, 88);
        text-align:       center;
        font-weight:      bold;
      }

      .NoneResult {
        background-color: rgb(105, 105, 105);
        text-align:       center;
        font-weight:      bold;
      }

      .InconclusiveResult {
        background-color: rgb(255, 165, 0);
        text-align:       center;
        font-weight:      bold;
      }

      .ErrorResult {
        background-color: rgb(205, 0, 0);
        text-align:       center;
        font-weight:      bold;
      }
      
      .Heading1 {
        font-family: arial, sans-serif;
        font-weight: bold;
        font-size:   26px;
      }
      
      .Heading2 {
        font-family: arial, sans-serif;
        font-weight: bold;
        font-size:   20px;
      }
      
      .Heading3 {
        font-family:   arial, sans-serif;
        font-weight:   bold;
        font-size:     18px;
        margin-bottom: 20px;
        margin-top:    20px;
      }
      
      .Heading4 {
        font-family:   arial, sans-serif;
        font-weight:   bold;
        font-size:     16px;
        margin-top:    10px;
        margin-bottom: 10px;
      }
      
      img {
        Margin-bottom: 10px;
        Margin-right:  10px;
      }
      
      p {
        Margin-bottom: 20px;
      }
      
      .DefaultTableBackground {
        background-color: rgb(229, 229, 229);
        border-spacing:   0px;
        padding:          0px;
      }
      
      .NegativeResultBackground {
        background-color: rgb(240, 0, 0);
        border-spacing:   0px;
        padding:          0px;
      }
      
      .PositiveResultBackground {
        background-color: rgb(25, 165, 88);
        border-spacing:   0px;
        padding:          0px;
      }
      
      .WarningResultBackground {
        background-color: rgb(255, 255, 0);
        border-spacing:   0px;
        padding:          0px;
      }
      
      .NoneResultBackground {
        background-color: rgb(105, 105, 105);
        border-spacing:   0px;
        padding:          0px;
      }
      
      .InconclusiveResultBackground {
        background-color: rgb(255, 165, 0);
        border-spacing:   0px;
        padding:          0px;
      }
      
      .ErrorResultBackground {
        background-color: rgb(205, 0, 0);
        border-spacing:   0px;
        padding:          0px;
      }
      
      .TestGroupHeadingBackground {
        background-color: rgb(179, 179, 179);
      }
    
      .Indentation {
        margin-left:  20px;
      }
    </style>
    <script type="text/javascript">
      var EXPANDED = '[−]';
      var COLLAPSED = '[+]';
      var VISIBLE = 'Visible';
      var HIDDEN = 'Hidden';
      var NONE = 'none';
      var BLOCK = '';
      function getDivId(id) { return 'div_' + id; }
      function getLinkId(id) { return 'lnk_' + id; }
      function getTableId(id) { return 'tbl_' + id; }
      function getTbl2Id(id) { return 'tbl_t' + id; }
      
      
      function switchText(oldText) { return oldText == COLLAPSED ? EXPANDED : COLLAPSED ; }
      function getStyleFromText(linkText) { return linkText == COLLAPSED ? HIDDEN : VISIBLE; }
      
      function getElements(tagName, elementId)
      {
        this.elements = [];
        var index = 0;
        var elm = document.getElementsByTagName(tagName);
        var len = elm.length;
        for (var i = 0; i < len; i++) 
        {
          var id = elm[i].id;
          if (id && id.indexOf(elementId) == 0)
          {
            this.elements[index] = elm[i];
            index++;
          }
        }
        return this.elements;
      }
      function matchElements(tagName, matchId)
      {
        this.elements = [];
        var index = 0;
        var elm = document.getElementsByTagName(tagName);
        for (var i = 0; i < elm.length; i++) 
        {
          var id = elm[i].id;
          var tc = id.replace(/s[0-9]+\./, "");
          if (tc && tc == matchId)
          {
            this.elements[index] = elm[i];
            index++;
          }
        }
        return this.elements;  
      }
      function onoff(elm, style)
      {
        if(elm.style.display == NONE)
        {
          if(style == null || style == VISIBLE)
            elm.style.display = BLOCK;
        }
        else
        {
          if(style == null || style == HIDDEN)
            elm.style.display = NONE;
        }
      }
      function switchTagStyle(tag, id, style)
      {
        var divs = getElements(tag, id);
        for(var i = 0; i < divs.length; i++)
          onoff(divs[i], style);
      }
      function switchRowStyle(tbl, style)
      {
        var rows = tbl.rows.length;
        for(var rowIndex=0; rowIndex < rows; rowIndex++)
        {
          var row = tbl.rows[rowIndex];
          if (row.id != "on")
            onoff(row, style);
        }
      }
      function switchTableRowStyle(tableId, style)
      {
        var tables = getElements('table', tableId);
        for(var i = 0; i < tables.length; i++)
          switchRowStyle(tables[i], style);
      }
      function switchLinkText(linkId, newText)
      {
        var link = getElements('a', linkId);
        var len = link.length;
        for(var i = 0; i < len; i++)
        {
          var lnk = link[i];
          if(newText == null)
          {
            var oldText = lnk.text;
            newText = switchText(oldText)
          }
          lnk.text = newText;
        }
      }
      function switchTag(tag, id, text)
      {
        var style = getStyleFromText(text);
        switchTagStyle(tag, id, style);
      }
      function switchTable(id)
      {
        switchLinkText(getTableId(id));
        switchTableRowStyle(getTableId(id));
      }
      function switchDiv(id, linkText)
      {
        var text = switchText(linkText);
        switchLinkText(getLinkId(id), text);
        switchTag('div', getDivId(id), text);
      }      
      function switchAll(id, linkText)
      {
        var text = switchText(linkText);
        switchLinkText(getLinkId(id), text);
        switchTag('div', getDivId(id), text);
        var style = getStyleFromText(text);
        switchTableRowStyle(getTbl2Id(id), style);
      }
      function showTable(id)
      {
        var tableId = getTableId(id);
        switchLinkText(tableId, EXPANDED);
        switchTableRowStyle(tableId, VISIBLE);
      }
      function hideTable(id)
      {
        var tableId = getTableId(id);
        switchTableRowStyle(tableId, HIDDEN);
        switchLinkText(tableId, COLLAPSED);
      }
      function showDiv(id)
      {
        switchLinkText(getLinkId(id), EXPANDED);
        switchTag('div', getDivId(id), EXPANDED);
      }
      function showTC(id)
      {
        var divId = getDivId(id);
        var elms = matchElements('div', divId); 
        if(elms != null && elms.length > 0)
        {
          id = elms[0].id.replace(getDivId(''), '');
          showDiv(id);
        }
      }
      
    </script>
  </head>
  <body>
    <a name="TOP"></a>
    <table class="HeadingTable">
      <tr>
        <td>
          <big class="Heading1">Report: ${title}</big>
        </td>
      </tr>
    </table>
    <center>
      <table class="OverallResultTable">
        <tr>
          <%
            globalCellClass = "NegativeResult"
            if global_result is True:
              globalCellClass = "PositiveResult"
          %>
          <td class=${globalCellClass}>
            % if global_result is True:
              Test Pass
            % else:
              Test Failed
            % endif
          </td>
        </tr>
      </table>
    </center>
    <a name="GeneralTestInfo"></a>
    <table class="SubHeadingTable">
      <tr>
        <td>
          <div class="Heading2">General Test Information</div>
        </td>
      </tr>
    </table>
    <div class="Indentation">
      <div class="Heading4">Test Engineer</div>
      <div class="Indentation">
        <table>
          <tr>
            <td class="CellNoColor">${test_engineer}</td>
          </tr>
        </table>
      </div>
      <div class="Heading4">Test Setup</div>
      <div class="Indentation">
        <table>
          <tr>
            <td class="CellNoColor">Version: </td>
            <td class="CellNoColor">${test_version}</td>
          </tr>
          <tr>
            <td class="CellNoColor">Configuration: </td>
            <td class="CellNoColor">${test_config}</td>
          </tr>
          <tr>
            <td class="CellNoColor">Test Module Name: </td>
            <td class="CellNoColor">${modules}</td>
          </tr>
        </table>
      </div>
      <div class="Heading4">Hardware</div>
      <div class="Indentation">
        <div class="Heading4">Ecu Board</div>
        <div class="Indentation">
          <table>
            <tr>
              <th class="TableHeadingCell">Platform</th>
              <th class="TableHeadingCell">Driver version</th>
              <th class="TableHeadingCell">Unit Test Framework version</th>
            </tr>
            <tr>
              <td class="NumberCell">${hardware_infomation["paltform"]}</td>
              <td class="NumberCell">${hardware_infomation["driver_version"]}</td>
              <td class="NumberCell">${hardware_infomation["framework_version"]}</td>
            </tr>
          </table>
        </div>
      </div>
      <div class="Indentation">
        <div class="Heading4">Log-System</div>
        <div class="Indentation">
          <table>
            <tr>
              <th class="TableHeadingCell">COM Number</th>
              <th class="TableHeadingCell">Baudrate</th>
              <th class="TableHeadingCell">Protocol</th>
            </tr>
            <tr>
              <td class="NumberCell">COM4</td>
              <td class="NumberCell">256000</td>
              <td class="NumberCell">0.0.0</td>
            </tr>
          </table>
        </div>
      </div>
      <div class="Heading4">Logging and video recordings</div>
      <div class="Indentation">
        <table>
          <th class="TableHeadingCell">Start Time</th>
          <th class="TableHeadingCell">End Time</th>
          <th class="TableHeadingCell">Logging/Video File</th>
        % for log in test_log_info:
          <tr>
            <td class="NumberCell">   ${log["begin_time"]}</td>
            <td class="NumberCell">   ${log["end_time"]}</td>
            <td class="NumberCell" style="text-align:left">${log["file_path"]}</td>
          </tr>
        % endfor
        </table>
      </div>
      <p><b>Measurement stop forced. Test is incomplete!</b></p>
    </div>
    <a name="TestOverview"></a>
    <table class="SubHeadingTable">
      <tr>
        <td>
          <div class="Heading2">Test Overview</div>
        </td>
      </tr>
    </table>
    <div class="Indentation">
      <table class="DefaultTable">
        <tr>
          <td style="padding-right: 0.5em;" class="CellNoColor">Test begin: </td>
          <td style="padding-right: 0.5em;" class="CellNoColor">${global_begin_time}</td>
        </tr>
        <tr>
          <td style="padding-right: 0.5em;" class="CellNoColor">Test end: </td>
          <td style="padding-right: 0.5em;" class="CellNoColor">${global_end_time}</td>
        </tr>
      </table>
      <div class="Heading4">Statistics</div>
      <div class="Indentation">
        <table class="OverviewTable">
          <tr>
            <td class="DefineCell">Overall number of test cases </td>
            <td class="NumberCell" width="60">${num_of_all_test_case}</td>
            <td class="DefaultCell"></td>
          </tr>
          <tr>
            <td class="DefineCell">Executed test cases </td>
            <td class="NumberCell">${num_of_exec_test_case}</td>
            <td class="DefaultCell">${int(100*num_of_exec_test_case/num_of_all_test_case)}% of all test cases</td>
          </tr>
          <tr>
            <td class="DefineCell">Not executed test cases </td>
            <td class="NumberCell">${num_of_all_test_case-num_of_exec_test_case}</td>
            <td class="DefaultCell">${100-int(100*num_of_exec_test_case/num_of_all_test_case)}%  of all test cases</td>
          </tr>
          <tr>
            <td class="DefineCell">Test cases passed </td>
            <% 
              num_of_fail_test_case = num_of_exec_test_case-num_of_pass_test_case
              numCellClass = "NumberCellNegativeResult"
              infoCellClass = "NumberCellNegativeResult"
              if num_of_fail_test_case == 0:
                numCellClass = "NumberCell"
                infoCellClass = "DefaultCell"
            %>
            <td class="NumberCell">${num_of_pass_test_case}</td>
            <td class="DefaultCell">${int(100*num_of_pass_test_case/num_of_exec_test_case)}% of executed test cases</td>
          </tr>
          <tr>
            <td class="DefineCell">Test cases failed </td>
            <td class=${numCellClass}>${num_of_exec_test_case-num_of_pass_test_case}</td>
            <td class=${infoCellClass}>${100-int(100*num_of_pass_test_case/num_of_exec_test_case)}% of executed test cases</td>
          </tr>
        </table>
      </div>
      <div class="Heading4">Test Case Results</div>
      <div class="Indentation">
        <table class="OverviewTable">
        % for item in test_cases_info:
          <% 
            resCellClass = "NegativeResultCell"
            result = "Fail"
            if item["result"] is True:
              resCellClass = "PositiveResultCell"         
              result = "Pass" 
            endif
          %>
          <tr>
            <td class="DefineCell">${item["index"]}</td>
            <td class="DefaultCell"></td>
            <td class="DefaultCell"><a href=${"#i__" + item["title"]}>${item["description"]}</a></td>
            <td class=${resCellClass}><a href=${"#i__" + item["title"]} onclick="showTC('${item["index"]}')">${result}</a></td>
          </tr>
        % endfor
        </table>
      </div>
    </div>
    <a name="TestModuleInfo"></a>
    <table class="SubHeadingTable">
      <tr>
        <td class="LinkCell">
          <a class="Undecorated" id="lnk_" href="javascript:switchAll('',document.all['lnk_'].text)">[−]</a>
        </td>
        <td>
          <div class="Heading2">Test Module Information</div>
        </td>
      </tr>
    </table>
    <table class="SubHeadingTable">
      <tr>
        <td>
          <big class="Heading2">Test Case Details</big>
        </td>
      </tr>
    </table>
  % for item in test_cases_info:
    <%
      headerClass = "TestcaseHeadingNegativeResult"
      resCellClass = "NegativeResultCell"
      result = "Failed"
      if item["result"] is True:
        headerClass = "TestcaseHeadingPositiveResult"
        resCellClass = "PositiveResultCell"         
        result = "Pass" 
      endif    
    %>
    <table>
      <tr>
        <td class="LinkCell">
          <a class="Undecorated" id=${"lnk_" + str(item["index"])} href=${"javascript:switchAll('" + str(item["index"]) + "',document.all['lnk_" + str(item["index"]) + "'].text)"}>[−]</a>
        </td>
        <td class=${headerClass}>
          <big class="Heading3">${item["index"]} <a name=${"i__" + item["title"]}>${item["description"]}</a>: ${result}</big>
        </td>
      </tr>
    </table>
    <div class="Indentation" id=${"div_" + str(item["index"])}>
      <div class="Indentation">
        <table class="DefaultTable">
          <tr>
            <td style="padding-right: 0.5em;" class="CellNoColor">Test case begin: </td>
            <td style="padding-right: 0.5em;" class="CellNoColor">${item["begin_time"]}</td>
            <td class="CellNoColor">(logging timestamp    ${item["begin_time_stamp"]})</td>
          </tr>
          <tr>
            <td style="padding-right: 0.5em;" class="CellNoColor">Test case end: </td>
            <td style="padding-right: 0.5em;" class="CellNoColor">${item["end_time"]}</td>
            <td class="CellNoColor" nowrap>(logging timestamp   ${item["end_time_stamp"]})</td>
          </tr>
        </table>
      </div>
      <div class="Indentation"></div>
      <table class="TestGroupHeadingBackground">
        <tr>
          <td>
            <big class="Heading3">Main Part of Test Case</big>
          </td>
        </tr>
      </table>
      <div class="Indentation">
        <table class="ResultTable">
          <tr>
            <th class="TableHeadingCell" width="1px">Timestamp</th>
            <th class="TableHeadingCell" width="1px">Test Step</th>
            <th class="TableHeadingCell" width="auto">API</th>
            <th class="TableHeadingCell" width="auto">Description</th>
            <th class="TableHeadingCell" width="1px">Result</th>
          </tr>
        % for step in item["steps"]:
          <%
            resCellClass = "DefaultCell"
            if step["result"] == "fail":
              resCellClass = "NegativeResultCell"
            elif step["result"] == "pass":
              resCellClass = "PositiveResultCell"
            endif
          %>
          <tr>
            <td class="DefineCell">${step["time_stamp"]}</td>
            <td class="NumberCell">${step["index"]}</td>
            <td class="DefaultCell">${step["api"]}</td>
            <td class="DefaultCell">${step["description"]}</td>
            <td class=${resCellClass}>${step["result"]}</td>
          </tr>
        % endfor
        </table>
      </div>
    </div>
  % endfor
    <table class="SubHeadingTable">
      <tr>
        <td>
          <div class="Heading2">End of Report</div>
        </td>
      </tr>
    </table>
  </body>
</html>
